Skip to content

chores: refactor internal build to call peg via "go tool"#192

Merged
pointlander merged 4 commits into
pointlander:mainfrom
dolmen-go:peg-as-internal-tool
May 19, 2026
Merged

chores: refactor internal build to call peg via "go tool"#192
pointlander merged 4 commits into
pointlander:mainfrom
dolmen-go:peg-as-internal-tool

Conversation

@dolmen
Copy link
Copy Markdown
Contributor

@dolmen dolmen commented May 18, 2026

  • Add peg as a tool: go get -tool .
  • Update //go:generate lines in grammars/, and generate-grammars.bash, bootstrap.bash to now execute peg via go tool peg

Benefits:

  • use modern features of the Go toolchain, towards more portability (to be even more contributor friendly)
  • running the peg tool via go tool ensures a fresh build from the latest local sources
  • shows the way for users how to use peg with a modern toolchain (go1.24+)

dolmen added 4 commits May 18, 2026 12:12
Now that that 'peg' itself is registered as a tool in go.mod we can call
it directly via 'go tool peg' in '//go:generate' lines (in grammars):
peg will be automatically built (and cached) as necessary.
* Simplify generate-grammars.bash using Go package patterns.
* Forward flags to 'go generate'

Example:
$ ./generate-grammars.bash -n
go tool peg -switch -inline c.peg
go tool peg -switch -inline calculator.peg
go tool peg -switch -inline calculator.peg
go tool peg -switch -inline fexl.peg
go tool peg -switch -inline java_1_7.peg
go tool peg -switch -inline long.peg
Use 'go tool peg' (instead of 'go build && ./peg') to run peg for
regenerating peg.peg.go.
@pointlander pointlander merged commit e818c91 into pointlander:main May 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants